<template>
  <div class="result-body">
    <div class="d-article-container layui-clear">
      <div class="article-l">
        <h3 class="al-title">写作材料</h3>
        <div class="al-con" v-html="articleText"></div>
      </div>
      <div class="article-r">
        <div class="ar-title">老师评分：<span class="color-red">{{userScore}}</span></div>
        <div class="ar-con">
          <p class="arc-title">您的答案</p>
          <div class="arc-con" v-html="showArticle"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: "MocksWriteDetail",
    props: {
      partInfo: Object
    },
    computed: {
      articleText () {
        let str = this.partInfo.content;
        return (str && typeof str === 'string') ? str.replace(/\n/g, '<br />').replace(/\t/g, '&nbsp;') : ''
      },
      userScore () {
        if (this.partInfo.question_list && this.partInfo.question_list.length) {
          let questionList = this.partInfo.question_list;
          let score = questionList[0].user_score ? questionList[0].user_score : 0;
          return score;
        }
      },
      showArticle () {
        if (this.partInfo.question_list && this.partInfo.question_list.length) {
          let questionList = this.partInfo.question_list;
          let str = questionList[0].user_answer;
          return (str && typeof str === 'string') ? str.replace(/\n/g, '<br />').replace(/\t/g, '&nbsp;') : '';
        }
      }
    }
  }
</script>

<style scoped>

</style>
